package com.ruoyi.hr.controller.hr.personstatisticsanalysis;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.Ztree;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.EmpSalaryService;
import com.ruoyi.hr.service.entryexitmanage.EntryExitManageService;
import com.ruoyi.hr.service.personstatisticsanalysis.EmpResumeService;
import com.ruoyi.hr.service.personstatisticsanalysis.PersonStatisticsanalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 员工履历
 * @date 2020/4/21
 */
@Controller
@RequestMapping("/personStatisticsAnalysis/empResume")
public class EmpResumeController extends BaseController {

    @Autowired
    AuthorityService authorityService;

    @Autowired
    EmpResumeService empResumeService;

    @Autowired
    PersonStatisticsanalysisService personStatisticsanalysisService;

    private String prefix = "hr/personStatisticsanalysis/empresume";


    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String empResume() {
        return prefix + "/empResume";
    }

    @GetMapping("/ChoiceEmp")
    public String ChoiceEmp() {
        return prefix + "/choiceEmp";
    }

    @RequestMapping("/findEmp")
    @ResponseBody
    public TableDataInfo findEmp(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        List<Map<String, Object>> list = personStatisticsanalysisService.findEmpList(map, authority);
        return getDataTable(list);
    }

    @RequestMapping("/getData")
    @ResponseBody
    public Map getData(String eid) {
        Map<String, Object> map = new HashMap<String, Object>();

        //基本信息
        Map<String, Object> basicInfoMap = empResumeService.findBasicInfo(eid);

        //合同信息
        List<Map<String,Object>> contractInfoMap = empResumeService.findContractInfo(eid);

        //工作经验
        List<Map<String, Object>> workInfoMap = empResumeService.workInfo(eid);

        //项目经验
        List<Map<String, Object>> proInfoMap = empResumeService.proInfoMap(eid);

        //教育经历
        List<Map<String, Object>> educationInfoMap = empResumeService.educationInfoMap(eid);

        //培训经历
        List<Map<String, Object>> trainingInfoMap = empResumeService.trainingInfoMap(eid);

        //人事变动
        List<Map<String, Object>> empChangeInfoMap = empResumeService.empChangeInfoMap(eid);

        //薪资变动
        List<Map<String, Object>> salaryInfoMap = empResumeService.salaryInfoMap(eid);

        //福利变动
        List<Map<String, Object>> beneChangeMap = empResumeService.beneChangeMap(eid);

        //考勤变动
        List<Map<String, Object>> attendChangeMap = empResumeService.attendChangeMap(eid);

        //绩效记录
        List<Map<String, Object>> pEmpResultInfoMap = empResumeService.pEmpResultInfoMap(eid);
        map.put("basicInfoMap",basicInfoMap);
        map.put("contractInfoMap",contractInfoMap);
        map.put("workInfoMap",workInfoMap);
        map.put("proInfoMap",proInfoMap);
        map.put("educationInfoMap",educationInfoMap);
        map.put("trainingInfoMap",trainingInfoMap);
        map.put("empChangeInfoMap",empChangeInfoMap);
        map.put("salaryInfoMap",salaryInfoMap);
        map.put("beneChangeMap",beneChangeMap);
        map.put("attendChangeMap",attendChangeMap);
        map.put("pEmpResultInfoMap",pEmpResultInfoMap);

        return map;
    }
}
